<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改表单元素字典')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-dict-edit" th:object="${dict}">
            <input name="dictId" th:field="*{dictId}" type="hidden">
            <input id="dictParent" name="dictParent" type="hidden"  th:field="*{dictParent}"  />
            <input id="dictPath" name="dictPath" type="hidden"  th:field="*{dictPath}"  />
            <input id="dictLinkId" name="dictLinkId" type="hidden"  th:field="*{dictLinkId}"  />

            <div class="form-group">
                <label class="col-sm-2 control-label">父字典：</label>
                <div class="col-sm-10">
                    <div class="input-group">
                        <input class="form-control" type="text" onclick="selectDictTree()" id="dictParentName" readonly="true" th:value="${parentName}">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label"><span style="color: red; ">*</span>字典代码：</label>
                <div class="col-sm-10">
                    <input name="dictCode" th:field="*{dictCode}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label"><span style="color: red; ">*</span>字典描述：</label>
                <div class="col-sm-10">
                    <input name="dictTitle" th:field="*{dictTitle}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">tip：</label>
                <div class="col-sm-10">
                    <input name="dictTip" th:field="*{dictTip}" class="form-control" type="text" >
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label"><span style="color: red; ">*</span>字典类型：</label>
                        <div class="col-sm-8">
                            <select name="dictType" class="form-control m-b" th:with="type=${@dict.getType('form_dict_type')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{dictType}"></option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label"><span style="color: red; ">*</span>排序：</label>
                        <div class="col-sm-8">
                            <input name="dictSeq" th:field="*{dictSeq}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">自动计算得分：</label>
                        <div class="col-sm-8">
                            <div class="radio-box" th:each="dict : ${@dict.getType('sys_yes_no')}">
                                <input type="radio" th:id="${dict.dictCode}" name="dictAutoScore" th:value="${dict.dictValue}" th:field="*{dictAutoScore}">
                                <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">得分：</label>
                        <div class="col-sm-8">
                            <input name="dictScore" th:field="*{dictScore}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">必填：</label>
                        <div class="col-sm-8">
                            <div class="radio-box" th:each="dict : ${@dict.getType('sys_yes_no')}">
                                <input type="radio" th:id="${dict.dictCode}" name="dictRequired" th:value="${dict.dictValue}" th:field="*{dictRequired}">
                                <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">标准得分：</label>
                        <div class="col-sm-8">
                            <input name="dictStandardScore" th:field="*{dictStandardScore}"  class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">rowspan：</label>
                        <div class="col-sm-8">
                            <input name="dictRowspan" th:field="*{dictRowspan}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">colspan：</label>
                        <div class="col-sm-8">
                            <input name="dictColspan" th:field="*{dictColspan}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">换行：</label>
                        <div class="col-sm-8">
                            <div class="radio-box" th:each="dict : ${@dict.getType('sys_yes_no')}">
                                <input type="radio" th:id="${dict.dictCode}" name="dictWrap" th:value="${dict.dictValue}" th:field="*{dictWrap}">
                                <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">默认值：</label>
                        <div class="col-sm-8">
                            <input name="dictDefaultValue" th:field="*{dictDefaultValue}" class="form-control" type="text" >
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">复制行：</label>
                        <div class="col-sm-8">
                            <div class="radio-box" th:each="dict : ${@dict.getType('sys_yes_no')}">
                                <input type="radio" th:id="${dict.dictCode}" name="dictCopy" th:value="${dict.dictValue}" th:field="*{dictCopy}">
                                <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">公共数据集：</label>
                        <div class="col-sm-8">
                            <div class="radio-box" th:each="dict : ${@dict.getType('sys_yes_no')}">
                                <input type="radio" th:id="${dict.dictCode}" name="dictDataSet" th:value="${dict.dictValue}" th:field="*{dictDataSet}">
                                <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">宽度：</label>
                        <div class="col-sm-8">
                            <input name="dictWidth" th:field="*{dictWidth}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">高度：</label>
                        <div class="col-sm-8">
                            <input name="dictHeight" th:field="*{dictHeight}" class="form-control" type="text">
                        </div>
                    </div>
                </div>
            </div>


            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">纵向扩展：</label>
                        <div class="col-sm-8">
                            <div class="radio-box" th:each="dict : ${@dict.getType('sys_yes_no')}">
                                <input type="radio" th:id="${dict.dictCode}" name="dictExpand" th:value="${dict.dictValue}" th:field="*{dictExpand}">
                                <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">数据集：</label>
                        <div class="col-sm-8">
                            <div class="input-group">
                                <input class="form-control" type="text" onclick="selectCommonDict()" id="dictLinkCode" readonly="true" th:value="${dictLinkCode}">
                                <span class="input-group-addon"><i class="fa fa-search"></i></span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">
                    <a class="btn btn-success btn-xs "
                       href="javascript:void(0)"
                       onclick="upload()">
                        附件 &nbsp&nbsp&nbsp&nbsp
                        <i class="fa fa-upload"></i>
                    </a>
                </label>
                <div class="col-sm-10" id="uploadList">

                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-2 control-label">备注：</label>
                <div class="col-xs-10">
                    <textarea name="remark" maxlength="5000" class="form-control" rows="3">[[*{remark}]]</textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script type="text/javascript">
        var prefix = ctx + "form/dict";

        $(function () {
            $("#form-dict-edit").validate({
                focusCleanup: true
            });
            $("#uploadList").html("")
            var fileId=$("#dictPath").val();
            if($.common.isNotEmpty(fileId)){
                var html='<p><a onclick="$.common.previewPic(\''+fileId+'\')"  >' + fileId +'</a></p>';
                $("#uploadList").html(html);
            }
        })

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-dict-edit').serialize());
            }
        }
        /*表单元素管理-新增-选择父字典树*/
        function selectDictTree() {
            var options = {
                title: '字典选择',
                maxmin: true,
                url: prefix + "/list" ,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var body = top.layer.getChildFrame('body', index);
            $("#dictParent").val(body.find('#id').val());
            $("#dictParentName").val(body.find('#name').val());
            top.layer.close(index);
        }

        /*数据集选择*/
        function selectCommonDict() {
            var options = {
                title: '公共数据集选择',
                maxmin: true,
                url: prefix + "/list?dictDataSet=Y" ,
                callBack: doSubmitCom
            };
            $.modal.openOptions(options);
        }

        function doSubmitCom(index, layero){
            var body = top.layer.getChildFrame('body', index);
            $("#dictLinkId").val(body.find('#id').val());
            $("#dictLinkCode").val(body.find('#name').val());
            top.layer.close(index);
        }

        function upload(){
            layerIndex=$.common.uploadFiles();
        }
        /**
         *  上传成功回调函数
         * @param arr
         */
        function uploadComplete(arr){
            if(arr.length>0){
                $("#uploadList").html("")
                $.common.addFileHtml("uploadList",arr);
                $("#dictPath").val(arr[0].fileName);
            }
            layer.close(layerIndex);
        }
    </script>
</body>
</html>